//
//  ExclusiveCollectionViewCell.m
//  DayByDay
//
//  Created by dllo on 16/5/13.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ExclusiveCollectionViewCell.h"
#import <UIImageView+WebCache.h>
#define EXCELLWIDTH self.contentView.frame.size.width
#define EXCellHEIGHT self.contentView.frame.size.height

@interface ExclusiveCollectionViewCell ()

@property (nonatomic, strong)UIImageView *imageV;
@property (nonatomic, strong)UILabel *nameLabe;
@property (nonatomic, strong)UILabel *descLabel;
@property (nonatomic, strong)UIImageView *smallImageV;
@property (nonatomic, strong)UILabel *lisonCountLabel;
@property (nonatomic, strong)UIImageView *lisionImageV;

@end

@implementation ExclusiveCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self createView];
    }
    return self;
}

- (void)createView {
    self.imageV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, EXCELLWIDTH, EXCELLWIDTH)];
    self.nameLabe = [[UILabel alloc] initWithFrame:CGRectMake(0, EXCELLWIDTH + 10 / 736.0 * HEIGHT, EXCELLWIDTH, 20 / 736.0 * HEIGHT)];
    self.descLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, EXCELLWIDTH + 30 / 736.0 * HEIGHT, EXCELLWIDTH, 10 / 736.0 * HEIGHT)];
    self.smallImageV = [[UIImageView alloc] initWithFrame:CGRectMake(self.imageV.frame.size.width - 30 / 736.0 * HEIGHT, self.imageV.frame.size.width - 30 / 736.0 * HEIGHT, 25 / 736.0 * HEIGHT, 25 / 736.0 * HEIGHT )];
    self.lisonCountLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.imageV.frame.size.width / 2, 5 / 736.0 * HEIGHT, self.imageV.frame.size.width / 2, 10 / 736.0 * HEIGHT)];
    self.lisionImageV = [[UIImageView alloc] initWithFrame:CGRectMake(self.imageV.frame.size.width / 2 - 20 / 736.0 * HEIGHT, 5 / 736.0 * HEIGHT, 10 / 736.0 * HEIGHT, 10 / 736.0 * HEIGHT)];
//    self.nameLabe.backgroundColor = [UIColor whiteColor];
//    self.descLabel.backgroundColor = [UIColor whiteColor];
    self.lisonCountLabel.backgroundColor = [UIColor clearColor];
    self.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.imageV];
    [self.contentView addSubview:self.nameLabe];
    [self.contentView addSubview:self.descLabel];
    [self.imageV addSubview:self.smallImageV];
    self.smallImageV.backgroundColor = [UIColor clearColor];
    [self.imageV addSubview:self.lisonCountLabel];
    self.lisonCountLabel.backgroundColor = [UIColor clearColor];
    [self.imageV addSubview:self.lisionImageV];
    self.lisionImageV.backgroundColor = [UIColor clearColor];
    
}

- (void)setModel:(DataModel *)model {
    _model = model;
    if (self.collectionViewTag == 10002 || self.collectionViewTag == 10003) {
        //        NSLog(@"dsfasdkl");
//        self.smallImageV.image = [UIImage imageNamed:@"entering_record_btn_play"];
    } else {
        self.smallImageV.image = nil;
    }
    if (_model.listenCount) {
        NSString *str =[NSString stringWithFormat:@"%.1f万", [_model.listenCount integerValue] / 10000.0 + 0.1];
        self.lisonCountLabel.text = str;
        self.lisionImageV.image = [UIImage imageNamed:@"Unknown-8"];
        self.smallImageV.image = [UIImage imageNamed:@"entering_record_btn_play"];
    }
    [self.imageV sd_setImageWithURL:[NSURL URLWithString:_model.picUrl] placeholderImage:[UIImage imageNamed:@"smiley_26"]];
    self.
    self.nameLabe.text = _model.name;
    self.descLabel.text = _model.desc;
    self.descLabel.font = [UIFont systemFontOfSize:14];
    self.descLabel.textColor = [UIColor darkGrayColor];
    self.lisonCountLabel.textColor = [UIColor lightGrayColor];
    self.lisonCountLabel.font = [UIFont systemFontOfSize:14];
}

@end
